package com.along.controller;

import com.along.entity.Dept;
import com.along.entity.DeptES;
import com.along.service.DeptSyncService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/*
 * @Author: liujinyi
 * @DateTime: 2025/7/4 16:39
 */
@RestController
@RequestMapping("/api/dept")
public class DeptSyncController {

    @Autowired
    private DeptSyncService deptSyncService;

    @PostMapping("/save")
    public String save(@RequestBody Dept dept) {
        deptSyncService.save(dept);
        return "保存成功";
    }

    @GetMapping("/search")
    public List<DeptES> search(@RequestParam String keyword) {
        return deptSyncService.searchFromEs(keyword);
    }

    @GetMapping("/list")
    public List<Dept> list() {
        return deptSyncService.findAllFromMysql();
    }
}
